<template>
    <div>
        <div class="top-main-container">
            <div class="title-view">
                <div class="title-item"></div>
            </div>
            <div class="bottom-view">
                <div class="left-view">
                    <div class="calendar-icon"></div>
                    <div class="date-text">{{curentDateTime}}</div>
                    <div class="week-text">{{weekDay}}</div>
                    <div class="time-text">{{hoursMinutes}}</div>
                </div>
                <div class="right-view" v-show="false">
                    <div class="weather-icon"></div>
                    <div class="weather-text">晴</div>
                    <div class="temperature-text">14℃</div>
                    <div class="user-icon"></div>
                    <div class="user-text">管理员</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import moment from 'moment/moment'

export default {
    name: 'topTitle',
    data(){
        return{
            weekDay:null,
            curentDateTime:null,
            hoursMinutes:null,
            timeInterval:null,
        }
    },
    methods:{
        setDate(){
            const weeks = ["日", "一", "二", "三", "四", "五", "六"]
            this.weekDay = '星期' + weeks[moment().format('E')]
            this.curentDateTime = moment().format("YYYY年MM月DD日")
            this.hoursMinutes = moment().format("HH:mm:ss")
        },
        showTimes() {
            this.timeInterval =  setInterval(() => {
                this.setDate()
            }, 1000);
        },
    },
    beforeDestroy () {
        clearInterval(this.timeInterval)
    },
    mounted () {
        this.setDate()
        this.showTimes()
    }
}
</script>

<style scoped lang="scss">
.top-main-container{
    width: 1917px;
    height: 79px;
    background: url("/static/img/big_data_top.png") no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    .title-view{
        width: 100%;
        height: 50px;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        .title-item{
            width: 258px;
            height: 30px;
            background: url("/static/img/big_data_title.png")no-repeat;
        }
    }

    .bottom-view{
        width: 100%;
        height: 29%;
        position: relative;

        .left-view{
            width: 700px;
            height: 100%;
            position: absolute;
            left: 0;
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: flex-start;

            .calendar-icon{
                width: 22px;
                height: 18px;
                background: url("/static/img/big_data_calendar.png") no-repeat;
                margin-left: 26px;
            }

            .date-text{
                color:#469CF7;
                margin-left: 20px;
            }

            .week-text{
                color:#FFFFFF;
                margin-left: 20px;
            }
            .time-text{
                color:#469CF7;
                margin-left: 20px;
            }

        }
        .right-view{
            width: 700px;
            height: 100%;
            position: absolute;
            right: 0;
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: flex-end;

            .weather-icon{
                width: 24px;
                height: 24px;
                background: url("/static/img/weather_icon.png") no-repeat;
                margin-right: 20px;
            }

            .weather-text{
                margin-right: 20px;
                color:#FFFFFF;
            }

            .temperature-text{
                margin-right: 20px;
                color:#469CF7;
            }

            .user-icon{
                width: 24px;
                height: 24px;
                background: url("/static/img/user_icon.png") no-repeat;
                margin-right: 20px;
            }
            .user-text{
                color:#469CF7;
                margin-right: 26px;
            }

        }

    }


}
</style>
